import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter);
// 解决重复点击路由报错的BUG
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err)
};


const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('@/views/HomeView.vue')
  },
  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import('../views/AboutView.vue')
  // },
  {
    path: '/403',
    component: () => import('@/components/error-page/403'),
    name: '403',
  },
  {
    path: '/404',
    component: () => import('@/components/error-page/404'),
    name: '404',
  },

  {
    path: '/500',
    component: () => import('@/components/error-page/500'),
    name: '500',
  },
  {
    path: '*',
    redirect: '/404'
  },


]

const router = new VueRouter({
  base: process.env.BASE_URL,
  routes
})

export default router
